package DatagramPlusPlus;


import java.io.IOException;
import java.net.DatagramSocket;

/**
 *
 * @author rafael
 */
public class WaitAndKill implements Runnable {

    private long timeOut;
    private DatagramSocket s;
    protected boolean done = false;

    public WaitAndKill(long timeout)    {
        timeOut = timeout;
    }

    public void run() {
        DatagramPlusPlusPacket packet =
                new DatagramPlusPlusPacket(new DatagramType(DatagramType.KILL));
        do{
            try {
                wait(timeOut);
                s.send(packet.getUDPPacket());
            } catch (IOException ex) {

            } catch (InterruptedException ex) {
            
            }
        }while(!done);

    }


}
